<?php
if ( !defined( "IN_OP" ) )
{
    exit( "You can't access this file directly..." );
}
$title = "系统管理员";
$ui = new UI();
include( "admin_menu.php" );
if ( isset( $_POST['id'] ) )
{
    $id = intval( $_POST['id'] );
    if ( $id == 0 )
    {
        $ui->showErrorPage( "错误的注单编号！" );
        exit();
    }
    $rs = getdb( "select * from bet where id=".$id );
    if ( $rs->eof )
    {
        $ui->showErrorPage( "错误的注单编号！" );
        exit();
    }
    if ( isset( $_POST['ok'] ) )
    {
        $editvar = $_POST['editvar'];
        if ( $editvar == "" )
        {
            echo "<font color=red><p>注单修改错误！</p></font>";
        }
        else
        {
            getdb( "update bet set numbers='".$editvar."' where id=".$id );
            echo "<p>注单修改完成！</p>";
        }
    }
    else
    {
        $btype = $rs->f['bettype'];
        if ( 7 <= $btype && $btype <= 11 )
        {
            echo "<form action=\"op.php?op=admin&fp=editbet\" method=post onsubmit=\"this.submit.disabled=true;this.reset.disabled=true\">";
            echo "<table border=1 cellpadding=3 cellspacing=0>";
            echo "<tr><td class=td0>注单编号<td>".$id;
            $u = get_user( $rs->f['user_id'] );
            echo "<tr><td class=td0>会员帐号<td>".$u['account'];
            echo "<tr><td class=td0>时间<td>".date( "m-d H:i:s", $rs->f['createtime'] );
            echo "<tr><td class=td0>期数<td>";
            $lotto = new lotto( $rs->f['lotto_id'] );
            echo d3( $lotto->data['round'] )." 期 <font color=#217952>".$lotto->data['open']."</font>";
            echo "<tr><td class=td0>注单内容<td>".GetBetContent( $rs->f['bettype'], $rs->f['numbers'], $rs->f['amount'] );
            $editvar = $rs->f['numbers'];
            echo "<tr><td class=td0>修改内容<td><input type=text name=editvar value=".$editvar." size=50>";
            echo "<tr><td class=td0>赔率<td>".show_rate( $rs->f['bettype'], $rs->f['rate'] );
            echo "<tr><td class=td0>金额<td>".$rs->f['amount'];
            echo "</table>";
            $stopbet = $conf->get( "calcbet" );
            if ( $stopbet )
            {
                echo "<p><font color=red>已经在执行颁奖统计了，无法修改该笔注单！</font></p>";
            }
            else
            {
                echo "<input type=hidden name=id value={$id}>";
                echo "<input type=hidden name=ok value=1>";
                echo "<p><input type=submit value=确定> <input type=button value=取消 onclick=\"location.href='op.php?op=admin&fp=editbet'\">";
            }
            echo "</form>";
        }
        else
        {
            echo "<p><font color=red>下注项目不在可修改范围内，无法修改该笔注单！</font></p>";
        }
    }
}
else
{
    echo "<b>修改注单内容</b><br>";
    echo "<form action=\"op.php?op=admin&fp=editbet\" method=post onsubmit=\"this.submit.disabled=true;this.reset.disabled=true\">";
    echo "请输入注单编号：<input name=id>";
    echo "<input type=submit value=确定>";
    echo "</form>";
}
?>